class UserSmsEmailsDailyStat < ActiveRecord::Base
  
  belongs_to :user
  
  validates_presence_of :user_id
  
  def self.today_stat_by_user_id(user_id)
    find_or_create_by_stated_on_and_user_id(Date.today,user_id)
  end
  
  def self.today_stat_by_mobile(mobile)
    today_stat_by_user_id(User.find_by_mobile(mobile))
  end
  
  def add_sms_count!(options = { :sms_count => 1, })
    options[:sms_count] ||=1
    self.sms_count += options[:sms_count]
    save
    #SmsEmailsDailyStat.today_stat.add_sms_count! if options[:sms_emails_daily_stat]
  end
  
  def add_emails_count!(options = { :emails_count => 1,  })
    options[:emails_count] ||=1
    self.emails_count += options[:emails_count]
    save
    #SmsEmailsDailyStat.today_stat.add_emails_count! if options[:sms_emails_daily_stat]
  end
  
end
